using UnityEngine;
using System.Collections;

public class FollowShip : MonoBehaviour {

	public Transform target;
	public float distance = 13f;
	public float height = 2f;
	public float rotationDamping = 0.1f;
	private Vector3 point;
	private Ray targetRay;
	//Quaternion camRotation = Quaternion.identity;
	//Vector3 campos;
	//Vector3 camUp;
	// Use this for initialization
	void Start () {
	
	}
	
	void LateUpdate() {
		
		targetRay = new Ray(target.position,-target.forward);

	    point = targetRay.GetPoint(distance);
	
	    point = Vector3.Slerp(transform.position, point, Time.deltaTime * rotationDamping);
	
	    transform.position = point + new Vector3(0, height, 0);
		
		transform.LookAt(target.position, target.up);
	}
	
	
	// Update is called once per frame
	//void Update () {
		
	//}
}
